home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_ORBit.idb / usr / freeware / include / libIDL / IDL.h.z / IDL.h
Encoding:
C/C++ Source or Header  |  1999-07-16  |  23.4 KB  |  852 lines

  1. /**************************************************************************
  2.  
  3.     IDL.h (IDL parse tree and namespace components)
  4.  
  5.     Copyright (C) 1998, 1999 Andrew T. Veliath
  6.  
  7.     This library is free software; you can redistribute it and/or
  8.     modify it under the terms of the GNU Library General Public
  9.     License as published by the Free Software Foundation; either
  10.     version 2 of the License, or (at your option) any later version.
  11.  
  12.     This library is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.     Library General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU Library General Public
  18.     License along with this library; if not, write to the Free
  19.     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21.     $Id: IDL.h.new.in,v 1.21 1999/06/14 21:14:22 andrewtv Exp $
  22.  
  23. ***************************************************************************/
  24. #ifndef __IDL_H
  25. #define __IDL_H
  26.  
  27. #include <glib.h>
  28.  
  29. /* Try to find wchar_t support */
  30. #include <stdlib.h>
  31. #if 1 /* HAVE_WCHAR_H */
  32. #  include <wchar.h>
  33. #endif
  34. #if 0 /* HAVE_WCSTR_H */
  35. #  include <wcstr.h>
  36. #endif
  37.  
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41.  
  42. /* version */
  43. #define LIBIDL_VERSION(a,b,c)        (((a) << 16) + ((b) << 8) + (c))
  44. #define LIBIDL_MAJOR_VERSION        0
  45. #define LIBIDL_MINOR_VERSION        6
  46. #define LIBIDL_MICRO_VERSION        8
  47. #define LIBIDL_VERSION_CODE        LIBIDL_VERSION(0,6,8)
  48.  
  49. /* miscellaneous constants */
  50. #define IDL_SUCCESS            0
  51. #define IDL_ERROR            1
  52. #define IDL_WARNING1            2
  53. #define IDL_WARNING2            3
  54. #define IDL_WARNING3            4
  55. #define IDL_WARNINGMAX            IDL_WARNING3
  56.  
  57. /* general parse flags */
  58. #define IDLF_VERBOSE            (1UL << 0)
  59. #define IDLF_NO_EVAL_CONST        (1UL << 1)
  60. #define IDLF_COMBINE_REOPENED_MODULES    (1UL << 2)
  61. #define IDLF_PREFIX_FILENAME        (1UL << 3)
  62. #define IDLF_IGNORE_FORWARDS        (1UL << 4)
  63. #define IDLF_PEDANTIC            (1UL << 5)
  64. #define IDLF_INHIBIT_TAG_ONLY        (1UL << 6)
  65. #define IDLF_INHIBIT_INCLUDES        (1UL << 7)
  66.  
  67. /* syntax extension parse flags */
  68. #define IDLF_TYPECODES            (1UL << 16)
  69. #define IDLF_XPIDL            (1UL << 17)
  70. #define IDLF_PROPERTIES            (1UL << 18)
  71. #define IDLF_CODEFRAGS            (1UL << 19)
  72.  
  73. /* declaration specification flags */
  74. #define IDLF_DECLSPEC_EXIST        (1UL << 0)
  75. #define IDLF_DECLSPEC_INHIBIT        (1UL << 1)
  76.  
  77. /* output flags */
  78. #define IDLF_OUTPUT_NO_NEWLINES        (1UL << 0)
  79. #define IDLF_OUTPUT_NO_QUALIFY_IDENTS    (1UL << 1)
  80. #define IDLF_OUTPUT_PROPERTIES        (1UL << 2)
  81. #define IDLF_OUTPUT_CODEFRAGS        (1UL << 3)
  82.  
  83. #ifdef _WIN32
  84. #  define IDL_EXPORT            __declspec (dllexport)
  85. #  define IDL_IMPORT            __declspec (dllimport)
  86. #else
  87. #  define IDL_EXPORT            /* empty */
  88. #  define IDL_IMPORT            extern
  89. #endif
  90.  
  91. /* type casting checks */
  92. #define IDL_check_cast_enable(boolean)    do {    \
  93.     IDL_IMPORT int __IDL_check_type_casts;    \
  94.     __IDL_check_type_casts = (boolean);    \
  95. } while (0)
  96. #define IDL_CHECK_CAST(tree, thetype, name)            \
  97.     (IDL_check_type_cast(tree, thetype,            \
  98.                 __FILE__, __LINE__,            \
  99.                 G_GNUC_PRETTY_FUNCTION)->u.name)
  100.  
  101. #ifdef G_HAVE_GINT64
  102. #  if G_MAXLONG > 0xffffffffUL
  103. #    define IDL_LL            "l"
  104. #  else
  105. #    define IDL_LL            "ll"
  106. #  endif
  107. typedef gint64                IDL_longlong_t;
  108. typedef guint64                IDL_ulonglong_t;
  109. #else
  110. #  define IDL_LL            "l"
  111. typedef long                IDL_longlong_t;
  112. typedef unsigned long            IDL_ulonglong_t;
  113. #  warning 64-bit integer type not available, using 32-bit instead
  114. #endif /* G_HAVE_GINT64 */
  115.  
  116. typedef unsigned int            IDL_declspec_t;
  117. typedef struct _IDL_tree_node         IDL_tree_node;
  118. typedef struct _IDL_tree_node *        IDL_tree;
  119.  
  120. struct _IDL_LIST {
  121.     IDL_tree data;
  122.     IDL_tree prev;
  123.     IDL_tree next;
  124.     IDL_tree _tail;            /* Internal use, may not be valid */
  125. };
  126.   
  127. #define IDL_LIST(a)            IDL_CHECK_CAST(a, IDLN_LIST, idl_list)
  128. extern IDL_tree        IDL_list_new            (IDL_tree data);
  129. extern IDL_tree        IDL_list_concat            (IDL_tree orig,
  130.                              IDL_tree append);
  131. extern IDL_tree        IDL_list_remove            (IDL_tree list,
  132.                              IDL_tree p);
  133. extern int        IDL_list_length            (IDL_tree list);
  134. extern IDL_tree        IDL_list_nth            (IDL_tree list,
  135.                              int n);
  136.  
  137. struct _IDL_GENTREE {
  138.     IDL_tree data;
  139.     GHashTable *siblings;
  140.     GHashTable *children;
  141.     GHashFunc hash_func;
  142.     GCompareFunc key_compare_func;
  143.     IDL_tree _import;        /* Internal use, do not recurse */
  144.     char *_cur_prefix;        /* Internal use */
  145. };
  146. #define IDL_GENTREE(a)            IDL_CHECK_CAST(a, IDLN_GENTREE, idl_gentree)
  147. extern IDL_tree        IDL_gentree_new            (GHashFunc hash_func,
  148.                              GCompareFunc key_compare_func,
  149.                              IDL_tree data);
  150. extern IDL_tree        IDL_gentree_new_sibling        (IDL_tree from,
  151.                              IDL_tree data);
  152. extern IDL_tree        IDL_gentree_chain_sibling    (IDL_tree from,
  153.                              IDL_tree data);
  154. extern IDL_tree        IDL_gentree_chain_child        (IDL_tree from,
  155.                              IDL_tree data);
  156.  
  157. struct _IDL_INTEGER {
  158.     IDL_longlong_t value;
  159. };
  160. #define IDL_INTEGER(a)            IDL_CHECK_CAST(a, IDLN_INTEGER, idl_integer)
  161. extern IDL_tree        IDL_integer_new            (IDL_longlong_t value);
  162.  
  163. struct _IDL_STRING {
  164.     char *value;
  165. };
  166. #define IDL_STRING(a)            IDL_CHECK_CAST(a, IDLN_STRING, idl_string)
  167. extern IDL_tree        IDL_string_new            (char *value);
  168.  
  169. struct _IDL_WIDE_STRING {
  170.     wchar_t *value;
  171. };
  172. #define IDL_WIDE_STRING(a)        IDL_CHECK_CAST(a, IDLN_WIDE_STRING, idl_wide_string)
  173. extern IDL_tree        IDL_wide_string_new        (wchar_t *value);
  174.  
  175. struct _IDL_CHAR {
  176.     char *value;
  177. };
  178. #define IDL_CHAR(a)            IDL_CHECK_CAST(a, IDLN_CHAR, idl_char)
  179. extern IDL_tree        IDL_char_new            (char *value);
  180.  
  181. struct _IDL_WIDE_CHAR {
  182.     wchar_t *value;
  183. };
  184. #define IDL_WIDE_CHAR(a)        IDL_CHECK_CAST(a, IDLN_WIDE_CHAR, idl_wide_char)
  185. extern IDL_tree        IDL_wide_char_new        (wchar_t *value);
  186.  
  187. struct _IDL_FIXED {
  188.     char *value;
  189. };
  190. #define IDL_FIXED(a)            IDL_CHECK_CAST(a, IDLN_FIXED, idl_fixed)
  191. extern IDL_tree        IDL_fixed_new            (char *value);
  192.  
  193. struct _IDL_FLOAT {
  194.     double value;
  195. };
  196. #define IDL_FLOAT(a)            IDL_CHECK_CAST(a, IDLN_FLOAT, idl_float)
  197. extern IDL_tree        IDL_float_new            (double value);
  198.  
  199. struct _IDL_BOOLEAN {
  200.     unsigned value;
  201. };
  202. #define IDL_BOOLEAN(a)            IDL_CHECK_CAST(a, IDLN_BOOLEAN, idl_boolean)
  203. extern IDL_tree        IDL_boolean_new            (unsigned value);
  204.  
  205. struct _IDL_IDENT {
  206.     char *str;
  207.     char *repo_id;
  208.     GSList *comments;
  209.     IDL_tree _ns_ref;        /* Internal use, do not recurse */
  210.     unsigned _flags;        /* Internal use */
  211. #define IDLF_IDENT_CASE_MISMATCH_HIT    (1UL << 0)
  212. };
  213. #define IDL_IDENT(a)            IDL_CHECK_CAST(a, IDLN_IDENT, idl_ident)
  214. #define IDL_IDENT_TO_NS(a)        IDL_CHECK_CAST(a, IDLN_IDENT, idl_ident._ns_ref)
  215. #define IDL_IDENT_REPO_ID(a)        IDL_CHECK_CAST(a, IDLN_IDENT, idl_ident.repo_id)
  216. extern IDL_tree        IDL_ident_new            (char *str);
  217. extern void        IDL_queue_new_ident_comment    (const char *str);
  218.  
  219. enum IDL_float_type {
  220.     IDL_FLOAT_TYPE_FLOAT,
  221.     IDL_FLOAT_TYPE_DOUBLE,
  222.     IDL_FLOAT_TYPE_LONGDOUBLE
  223. };
  224.  
  225. struct _IDL_TYPE_FLOAT {
  226.     enum IDL_float_type f_type;
  227. };
  228. #define IDL_TYPE_FLOAT(a)        IDL_CHECK_CAST(a, IDLN_TYPE_FLOAT, idl_type_float)
  229. extern IDL_tree        IDL_type_float_new        (enum IDL_float_type f_type);
  230.  
  231. struct _IDL_TYPE_FIXED {
  232.     IDL_tree positive_int_const;
  233.     IDL_tree integer_lit;
  234. };
  235. #define IDL_TYPE_FIXED(a)        IDL_CHECK_CAST(a, IDLN_TYPE_FIXED, idl_type_fixed)
  236. extern IDL_tree        IDL_type_fixed_new        (IDL_tree positive_int_const,
  237.                              IDL_tree integer_lit);
  238.  
  239. enum IDL_integer_type {
  240.     IDL_INTEGER_TYPE_SHORT,
  241.     IDL_INTEGER_TYPE_LONG,
  242.     IDL_INTEGER_TYPE_LONGLONG
  243. };
  244.  
  245. struct _IDL_TYPE_INTEGER {
  246.     unsigned f_signed        : 1;
  247.     enum IDL_integer_type f_type;
  248. };
  249. #define IDL_TYPE_INTEGER(a)        IDL_CHECK_CAST(a, IDLN_TYPE_INTEGER, idl_type_integer)
  250. extern IDL_tree        IDL_type_integer_new        (unsigned f_signed,
  251.                              enum IDL_integer_type f_type);
  252.  
  253. extern IDL_tree        IDL_type_char_new        (void);
  254. extern IDL_tree        IDL_type_wide_char_new        (void);
  255. extern IDL_tree        IDL_type_boolean_new        (void);
  256. extern IDL_tree        IDL_type_octet_new        (void);
  257. extern IDL_tree        IDL_type_any_new        (void);
  258. extern IDL_tree        IDL_type_object_new        (void);
  259. extern IDL_tree        IDL_type_typecode_new        (void);
  260.  
  261. struct _IDL_TYPE_STRING {
  262.     IDL_tree positive_int_const;
  263. };
  264. #define IDL_TYPE_STRING(a)        IDL_CHECK_CAST(a, IDLN_TYPE_STRING, idl_type_string)
  265. extern IDL_tree        IDL_type_string_new        (IDL_tree positive_int_const);
  266.  
  267. struct _IDL_TYPE_WIDE_STRING {
  268.     IDL_tree positive_int_const;
  269. };
  270. #define IDL_TYPE_WIDE_STRING(a)        IDL_CHECK_CAST(a, IDLN_TYPE_WIDE_STRING, idl_type_wide_string)
  271. extern IDL_tree        IDL_type_wide_string_new    (IDL_tree positive_int_const);
  272.  
  273. struct _IDL_TYPE_ENUM {
  274.     IDL_tree ident;
  275.     IDL_tree enumerator_list;
  276. };
  277. #define IDL_TYPE_ENUM(a)        IDL_CHECK_CAST(a, IDLN_TYPE_ENUM, idl_type_enum)
  278. extern IDL_tree        IDL_type_enum_new        (IDL_tree ident,
  279.                              IDL_tree enumerator_list);
  280.  
  281. struct _IDL_TYPE_ARRAY {
  282.     IDL_tree ident;
  283.     IDL_tree size_list;
  284. };
  285. #define IDL_TYPE_ARRAY(a)        IDL_CHECK_CAST(a, IDLN_TYPE_ARRAY, idl_type_array)
  286. extern IDL_tree        IDL_type_array_new        (IDL_tree ident,
  287.                              IDL_tree size_list);
  288.  
  289. struct _IDL_TYPE_SEQUENCE {
  290.     IDL_tree simple_type_spec;
  291.     IDL_tree positive_int_const;
  292. };
  293. #define IDL_TYPE_SEQUENCE(a)        IDL_CHECK_CAST(a, IDLN_TYPE_SEQUENCE, idl_type_sequence)
  294. extern IDL_tree        IDL_type_sequence_new        (IDL_tree simple_type_spec,
  295.                              IDL_tree positive_int_const);
  296.  
  297. struct _IDL_TYPE_STRUCT {
  298.     IDL_tree ident;
  299.     IDL_tree member_list;
  300. };
  301. #define IDL_TYPE_STRUCT(a)        IDL_CHECK_CAST(a, IDLN_TYPE_STRUCT, idl_type_struct)
  302. extern IDL_tree        IDL_type_struct_new        (IDL_tree ident,
  303.                              IDL_tree member_list);
  304.  
  305. struct _IDL_TYPE_UNION {
  306.     IDL_tree ident;
  307.     IDL_tree switch_type_spec;
  308.     IDL_tree switch_body;
  309. };
  310. #define IDL_TYPE_UNION(a)        IDL_CHECK_CAST(a, IDLN_TYPE_UNION, idl_type_union)
  311. extern IDL_tree        IDL_type_union_new        (IDL_tree ident,
  312.                              IDL_tree switch_type_spec,
  313.                              IDL_tree switch_body);
  314. struct _IDL_MEMBER {
  315.     IDL_tree type_spec;
  316.     IDL_tree dcls;
  317. };
  318. #define IDL_MEMBER(a)            IDL_CHECK_CAST(a, IDLN_MEMBER, idl_member)
  319. extern IDL_tree        IDL_member_new            (IDL_tree type_spec,
  320.                              IDL_tree dcls);
  321.  
  322. struct _IDL_NATIVE {
  323.     IDL_tree ident;
  324.     char *user_type;        /* XPIDL extension */
  325. };
  326. #define IDL_NATIVE(a)            IDL_CHECK_CAST(a, IDLN_NATIVE, idl_native)
  327. extern IDL_tree        IDL_native_new            (IDL_tree ident);
  328.  
  329.  
  330. struct _IDL_TYPE_DCL {
  331.     IDL_tree type_spec;
  332.     IDL_tree dcls;
  333. };
  334. #define IDL_TYPE_DCL(a)            IDL_CHECK_CAST(a, IDLN_TYPE_DCL, idl_type_dcl)
  335. extern IDL_tree        IDL_type_dcl_new        (IDL_tree type_spec,
  336.                              IDL_tree dcls);
  337.  
  338. struct _IDL_CONST_DCL {
  339.     IDL_tree const_type;
  340.     IDL_tree ident;
  341.     IDL_tree const_exp;
  342. };
  343. #define IDL_CONST_DCL(a)        IDL_CHECK_CAST(a, IDLN_CONST_DCL, idl_const_dcl)
  344. extern IDL_tree        IDL_const_dcl_new        (IDL_tree const_type,
  345.                              IDL_tree ident,
  346.                              IDL_tree const_exp);
  347.  
  348. struct _IDL_EXCEPT_DCL {
  349.     IDL_tree ident;
  350.     IDL_tree members;
  351. };
  352. #define IDL_EXCEPT_DCL(a)        IDL_CHECK_CAST(a, IDLN_EXCEPT_DCL, idl_except_dcl)
  353. extern IDL_tree        IDL_except_dcl_new        (IDL_tree ident,
  354.                              IDL_tree members);
  355.  
  356. struct _IDL_ATTR_DCL {
  357.     unsigned f_readonly        : 1;
  358.     IDL_tree param_type_spec;
  359.     IDL_tree simple_declarations;
  360. };
  361. #define IDL_ATTR_DCL(a)            IDL_CHECK_CAST(a, IDLN_ATTR_DCL, idl_attr_dcl)
  362. extern IDL_tree        IDL_attr_dcl_new        (unsigned f_readonly,
  363.                              IDL_tree param_type_spec,
  364.                              IDL_tree simple_declarations);
  365.  
  366. struct _IDL_OP_DCL {
  367.     unsigned __f_noscript        : 1;    /* Deprecated */
  368.     unsigned f_oneway        : 1;
  369.     /* XPIDL extension (varags) */
  370.     unsigned f_varargs        : 1;
  371.     IDL_tree op_type_spec;
  372.     IDL_tree ident;
  373.     IDL_tree parameter_dcls;
  374.     IDL_tree raises_expr;
  375.     IDL_tree context_expr;
  376. };
  377. #define IDL_OP_DCL(a)            IDL_CHECK_CAST(a, IDLN_OP_DCL, idl_op_dcl)
  378. extern IDL_tree        IDL_op_dcl_new            (unsigned f_oneway,
  379.                              IDL_tree op_type_spec,
  380.                              IDL_tree ident,
  381.                              IDL_tree parameter_dcls,
  382.                              IDL_tree raises_expr,
  383.                              IDL_tree context_expr);
  384.  
  385. enum IDL_param_attr {
  386.     IDL_PARAM_IN,
  387.     IDL_PARAM_OUT,
  388.     IDL_PARAM_INOUT
  389. };
  390.  
  391. struct _IDL_PARAM_DCL {
  392.     enum IDL_param_attr attr;
  393.     IDL_tree param_type_spec;
  394.     IDL_tree simple_declarator;
  395. };
  396. #define IDL_PARAM_DCL(a)        IDL_CHECK_CAST(a, IDLN_PARAM_DCL, idl_param_dcl)
  397. extern IDL_tree        IDL_param_dcl_new        (enum IDL_param_attr attr,
  398.                              IDL_tree param_type_spec,
  399.                              IDL_tree simple_declarator);
  400.  
  401. struct _IDL_CASE_STMT {
  402.     IDL_tree labels;
  403.     IDL_tree element_spec;
  404. };
  405. #define IDL_CASE_STMT(a)        IDL_CHECK_CAST(a, IDLN_CASE_STMT, idl_case_stmt)
  406. extern IDL_tree        IDL_case_stmt_new        (IDL_tree labels,
  407.                              IDL_tree element_spec);
  408.  
  409. struct _IDL_INTERFACE {
  410.     IDL_tree ident;
  411.     IDL_tree inheritance_spec;
  412.     IDL_tree body;
  413. };
  414. #define IDL_INTERFACE(a)        IDL_CHECK_CAST(a, IDLN_INTERFACE, idl_interface)
  415. extern IDL_tree        IDL_interface_new        (IDL_tree ident,
  416.                              IDL_tree inheritance_spec,
  417.                              IDL_tree body);
  418.  
  419. struct _IDL_FORWARD_DCL {
  420.     IDL_tree ident;
  421. };
  422. #define IDL_FORWARD_DCL(a)        IDL_CHECK_CAST(a, IDLN_FORWARD_DCL, idl_forward_dcl)
  423. extern IDL_tree        IDL_forward_dcl_new        (IDL_tree ident);
  424.  
  425. struct _IDL_MODULE {
  426.     IDL_tree ident;
  427.     IDL_tree definition_list;
  428. };
  429. #define IDL_MODULE(a)            IDL_CHECK_CAST(a, IDLN_MODULE, idl_module)
  430. extern IDL_tree        IDL_module_new            (IDL_tree ident,
  431.                              IDL_tree definition_list);
  432.  
  433. enum IDL_binop {
  434.     IDL_BINOP_OR,
  435.     IDL_BINOP_XOR,
  436.     IDL_BINOP_AND,
  437.     IDL_BINOP_SHR,
  438.     IDL_BINOP_SHL,
  439.     IDL_BINOP_ADD,
  440.     IDL_BINOP_SUB,
  441.     IDL_BINOP_MULT,
  442.     IDL_BINOP_DIV,
  443.     IDL_BINOP_MOD
  444. };
  445.  
  446. struct _IDL_BINOP {
  447.     enum IDL_binop op;
  448.     IDL_tree left, right;
  449. };
  450. #define IDL_BINOP(a)            IDL_CHECK_CAST(a, IDLN_BINOP, idl_binop)
  451. extern IDL_tree        IDL_binop_new            (enum IDL_binop op,
  452.                              IDL_tree left,
  453.                              IDL_tree right);
  454.  
  455. enum IDL_unaryop {
  456.     IDL_UNARYOP_PLUS,
  457.     IDL_UNARYOP_MINUS,
  458.     IDL_UNARYOP_COMPLEMENT
  459. };
  460.  
  461. struct _IDL_UNARYOP {
  462.     enum IDL_unaryop op;
  463.     IDL_tree operand;
  464. };
  465. #define IDL_UNARYOP(a)            IDL_CHECK_CAST(a, IDLN_UNARYOP, idl_unaryop)
  466. extern IDL_tree        IDL_unaryop_new            (enum IDL_unaryop op,
  467.                              IDL_tree operand);
  468.  
  469. /* XPIDL code fragments extension. */
  470. struct _IDL_CODEFRAG {
  471.     char *desc;
  472.     GSList *lines;
  473. };
  474. #define IDL_CODEFRAG(a)            IDL_CHECK_CAST(a, IDLN_CODEFRAG, idl_codefrag)
  475. extern IDL_tree        IDL_codefrag_new        (char *desc,
  476.                              GSList *lines);
  477.  
  478. /*
  479.  * IDL_tree_type - Enumerations of node types
  480.  *
  481.  * Note this enumerator list is subject to change in the future. A program should not need
  482.  * more than a recompilation to adjust for a change in this list, so instead of using a
  483.  * statically initialized jumptable, allocate an array of size IDLN_LAST and assign the
  484.  * elements manually.
  485.  */
  486. typedef enum {
  487.     IDLN_NONE,
  488.     IDLN_ANY,
  489.  
  490.     IDLN_LIST,
  491.     IDLN_GENTREE,
  492.     IDLN_INTEGER,
  493.     IDLN_STRING,
  494.     IDLN_WIDE_STRING,
  495.     IDLN_CHAR,
  496.     IDLN_WIDE_CHAR,
  497.     IDLN_FIXED,
  498.     IDLN_FLOAT,
  499.     IDLN_BOOLEAN,
  500.     IDLN_IDENT,
  501.     IDLN_TYPE_DCL,
  502.     IDLN_CONST_DCL,
  503.     IDLN_EXCEPT_DCL,
  504.     IDLN_ATTR_DCL,
  505.     IDLN_OP_DCL,
  506.     IDLN_PARAM_DCL,
  507.     IDLN_FORWARD_DCL,
  508.     IDLN_TYPE_INTEGER,
  509.     IDLN_TYPE_FLOAT,
  510.     IDLN_TYPE_FIXED,
  511.     IDLN_TYPE_CHAR,
  512.     IDLN_TYPE_WIDE_CHAR,
  513.     IDLN_TYPE_STRING,
  514.     IDLN_TYPE_WIDE_STRING,
  515.     IDLN_TYPE_BOOLEAN,
  516.     IDLN_TYPE_OCTET,
  517.     IDLN_TYPE_ANY,
  518.     IDLN_TYPE_OBJECT,
  519.     IDLN_TYPE_TYPECODE,
  520.     IDLN_TYPE_ENUM,
  521.     IDLN_TYPE_SEQUENCE,
  522.     IDLN_TYPE_ARRAY,
  523.     IDLN_TYPE_STRUCT,
  524.     IDLN_TYPE_UNION,
  525.     IDLN_MEMBER,
  526.     IDLN_NATIVE,
  527.     IDLN_CASE_STMT,
  528.     IDLN_INTERFACE,
  529.     IDLN_MODULE,
  530.     IDLN_BINOP,
  531.     IDLN_UNARYOP,
  532.     IDLN_CODEFRAG,
  533.  
  534.     IDLN_LAST
  535. } IDL_tree_type;
  536. IDL_IMPORT const char *            IDL_tree_type_names[];
  537.  
  538. struct _IDL_tree_node {
  539.     IDL_tree_type _type;
  540.     IDL_tree up;            /* Do not recurse */
  541.     IDL_declspec_t declspec;
  542.     GHashTable *properties;
  543.     int refs;
  544.     char *_file;            /* Internal use */
  545.     int _line;            /* Internal use */
  546.     union {
  547.         struct _IDL_LIST idl_list;
  548.         struct _IDL_GENTREE idl_gentree;
  549.         struct _IDL_INTEGER idl_integer;
  550.         struct _IDL_STRING idl_string;
  551.         struct _IDL_WIDE_STRING idl_wide_string;
  552.         struct _IDL_CHAR idl_char;
  553.         struct _IDL_WIDE_CHAR idl_wide_char;
  554.         struct _IDL_FIXED idl_fixed;
  555.         struct _IDL_FLOAT idl_float;
  556.         struct _IDL_BOOLEAN idl_boolean;
  557.         struct _IDL_IDENT idl_ident;
  558.         struct _IDL_TYPE_DCL idl_type_dcl;
  559.         struct _IDL_CONST_DCL idl_const_dcl;
  560.         struct _IDL_EXCEPT_DCL idl_except_dcl;
  561.         struct _IDL_ATTR_DCL idl_attr_dcl;
  562.         struct _IDL_OP_DCL idl_op_dcl;
  563.         struct _IDL_PARAM_DCL idl_param_dcl;
  564.         struct _IDL_FORWARD_DCL idl_forward_dcl;
  565.         struct _IDL_TYPE_FLOAT idl_type_float;
  566.         struct _IDL_TYPE_FIXED idl_type_fixed;
  567.         struct _IDL_TYPE_INTEGER idl_type_integer;
  568.         struct _IDL_TYPE_ENUM idl_type_enum;
  569.         struct _IDL_TYPE_STRING idl_type_string;
  570.         struct _IDL_TYPE_WIDE_STRING idl_type_wide_string;
  571.         struct _IDL_TYPE_SEQUENCE idl_type_sequence;
  572.         struct _IDL_TYPE_ARRAY idl_type_array;
  573.         struct _IDL_TYPE_STRUCT idl_type_struct;
  574.         struct _IDL_TYPE_UNION idl_type_union;
  575.         struct _IDL_MEMBER idl_member;
  576.         struct _IDL_NATIVE idl_native;
  577.         struct _IDL_CASE_STMT idl_case_stmt;
  578.         struct _IDL_INTERFACE idl_interface;
  579.         struct _IDL_MODULE idl_module;
  580.         struct _IDL_BINOP idl_binop;
  581.         struct _IDL_UNARYOP idl_unaryop;
  582.         struct _IDL_CODEFRAG idl_codefrag;
  583.     } u;
  584.  
  585.     /* Fields for application use */
  586.     guint32 flags;
  587.     gpointer data;
  588. };
  589. #define IDL_NODE_TYPE(a)        ((a)->_type)
  590. #define IDL_NODE_TYPE_NAME(a)        ((a)?IDL_tree_type_names[IDL_NODE_TYPE(a)]:"NULL")
  591. #define IDL_NODE_UP(a)            ((a)->up)
  592. #define IDL_NODE_PROPERTIES(a)        ((a)->properties)
  593. #define IDL_NODE_DECLSPEC(a)        ((a)->declspec)
  594. #define IDL_NODE_REFS(a)        ((a)->refs)
  595. #define IDL_NODE_IS_LITERAL(a)                \
  596.     (IDL_NODE_TYPE(a) == IDLN_INTEGER ||        \
  597.      IDL_NODE_TYPE(a) == IDLN_STRING ||        \
  598.      IDL_NODE_TYPE(a) == IDLN_WIDE_STRING ||    \
  599.      IDL_NODE_TYPE(a) == IDLN_CHAR ||        \
  600.      IDL_NODE_TYPE(a) == IDLN_WIDE_CHAR ||        \
  601.      IDL_NODE_TYPE(a) == IDLN_FIXED ||        \
  602.      IDL_NODE_TYPE(a) == IDLN_FLOAT ||        \
  603.      IDL_NODE_TYPE(a) == IDLN_BOOLEAN)
  604. #define IDL_NODE_IS_TYPE(a)                \
  605.     (IDL_NODE_TYPE(a) == IDLN_TYPE_INTEGER ||    \
  606.      IDL_NODE_TYPE(a) == IDLN_TYPE_STRING ||    \
  607.      IDL_NODE_TYPE(a) == IDLN_TYPE_WIDE_STRING ||    \
  608.      IDL_NODE_TYPE(a) == IDLN_TYPE_CHAR ||        \
  609.      IDL_NODE_TYPE(a) == IDLN_TYPE_WIDE_CHAR ||    \
  610.      IDL_NODE_TYPE(a) == IDLN_TYPE_FIXED ||        \
  611.      IDL_NODE_TYPE(a) == IDLN_TYPE_FLOAT ||        \
  612.      IDL_NODE_TYPE(a) == IDLN_TYPE_BOOLEAN ||    \
  613.      IDL_NODE_TYPE(a) == IDLN_TYPE_OCTET ||        \
  614.      IDL_NODE_TYPE(a) == IDLN_TYPE_ANY ||        \
  615.      IDL_NODE_TYPE(a) == IDLN_TYPE_OBJECT ||    \
  616.      IDL_NODE_TYPE(a) == IDLN_TYPE_TYPECODE ||    \
  617.      IDL_NODE_TYPE(a) == IDLN_TYPE_ENUM ||        \
  618.      IDL_NODE_TYPE(a) == IDLN_TYPE_ARRAY ||        \
  619.      IDL_NODE_TYPE(a) == IDLN_TYPE_SEQUENCE ||    \
  620.      IDL_NODE_TYPE(a) == IDLN_TYPE_STRUCT ||    \
  621.      IDL_NODE_TYPE(a) == IDLN_TYPE_UNION)
  622. #define IDL_NODE_IS_SCOPED(a)                \
  623.     (IDL_NODE_TYPE(a) == IDLN_IDENT ||        \
  624.      IDL_NODE_TYPE(a) == IDLN_INTERFACE ||        \
  625.      IDL_NODE_TYPE(a) == IDLN_MODULE ||        \
  626.      IDL_NODE_TYPE(a) == IDLN_EXCEPT_DCL ||        \
  627.      IDL_NODE_TYPE(a) == IDLN_OP_DCL ||        \
  628.      IDL_NODE_TYPE(a) == IDLN_TYPE_ENUM ||        \
  629.      IDL_NODE_TYPE(a) == IDLN_TYPE_STRUCT ||    \
  630.      IDL_NODE_TYPE(a) == IDLN_TYPE_UNION)
  631.  
  632. typedef struct _IDL_ns *        IDL_ns;
  633.  
  634. struct _IDL_ns {
  635.     IDL_tree global;
  636.     IDL_tree file;
  637.     IDL_tree current;
  638.     GHashTable *inhibits;
  639.     GHashTable *filename_hash;
  640. };
  641. #define IDL_NS(a)            (*(a))
  642.  
  643. typedef enum {
  644.     IDL_INPUT_REASON_INIT,
  645.     IDL_INPUT_REASON_FILL,
  646.     IDL_INPUT_REASON_ABORT,
  647.     IDL_INPUT_REASON_FINISH
  648. } IDL_input_reason;
  649.  
  650. union IDL_input_data {
  651.     struct {
  652.         const char *filename;
  653.     } init;
  654.     struct {
  655.         char *buffer;
  656.         size_t max_size;
  657.     } fill;
  658. };
  659.  
  660. typedef int        (*IDL_input_callback)        (IDL_input_reason reason,
  661.                              union IDL_input_data *data,
  662.                              gpointer user_data);
  663.  
  664. typedef int        (*IDL_msg_callback)        (int level,
  665.                              int num,
  666.                              int line,
  667.                              const char *filename,
  668.                              const char *message);
  669.  
  670. typedef struct _IDL_tree_func_state    IDL_tree_func_state;
  671. typedef struct _IDL_tree_func_data    IDL_tree_func_data;
  672.  
  673. /* Traversal state data.  Recursive walks chain states. */
  674. struct _IDL_tree_func_state {
  675.     IDL_tree_func_state *up;
  676.     IDL_tree start;
  677.     IDL_tree_func_data *bottom;
  678. };
  679.  
  680. /* This holds a list of the up hierarchy traversed, beginning from traversal.  This is
  681.  * useful since nodes referenced after initial definition will have a different traversal
  682.  * path than the actual up path. */
  683. struct _IDL_tree_func_data {
  684.     IDL_tree_func_state *state;
  685.     IDL_tree_func_data *up;
  686.     IDL_tree tree;
  687.     gint step;
  688.     gpointer data;        /* Application data */
  689. };
  690.  
  691. typedef gboolean    (*IDL_tree_func)        (IDL_tree_func_data *tnfd,
  692.                              gpointer user_data);
  693.  
  694. extern IDL_tree        IDL_check_type_cast        (const IDL_tree var,
  695.                              IDL_tree_type type,
  696.                              const char *file,
  697.                              int line,
  698.                              const char *function);
  699.  
  700. extern const char *    IDL_get_libver_string        (void);
  701.  
  702. extern const char *    IDL_get_IDLver_string        (void);
  703.  
  704. extern int        IDL_parse_filename        (const char *filename,
  705.                              const char *cpp_args,
  706.                              IDL_msg_callback msg_cb,
  707.                              IDL_tree *tree, IDL_ns *ns,
  708.                              unsigned long parse_flags,
  709.                              int max_msg_level);
  710.  
  711. extern int        IDL_parse_filename_with_input    (const char *filename,
  712.                              IDL_input_callback input_cb,
  713.                              gpointer input_cb_user_data,
  714.                              IDL_msg_callback msg_cb,
  715.                              IDL_tree *tree, IDL_ns *ns,
  716.                              unsigned long parse_flags,
  717.                              int max_msg_level);
  718.  
  719. extern int        IDL_ns_prefix            (IDL_ns ns,
  720.                              const char *s);
  721.  
  722. extern void        IDL_ns_ID            (IDL_ns ns,
  723.                              const char *s);
  724.  
  725. extern void        IDL_ns_version            (IDL_ns ns,
  726.                              const char *s);
  727.  
  728. extern int        IDL_inhibit_get            (void);
  729.  
  730. extern void        IDL_inhibit_push        (void);
  731.  
  732. extern void        IDL_inhibit_pop            (void);
  733.  
  734. extern void        IDL_file_set            (const char *filename,
  735.                              int line);
  736.  
  737. extern void        IDL_file_get            (const char **filename,
  738.                              int *line);
  739.  
  740. extern IDL_tree        IDL_get_parent_node        (IDL_tree p,
  741.                              IDL_tree_type type,
  742.                              int *scope_levels);
  743.  
  744. extern IDL_tree        IDL_tree_get_scope        (IDL_tree p);
  745.  
  746. extern int        IDL_tree_get_node_info        (IDL_tree tree,
  747.                              char **who,
  748.                              char **what);
  749.  
  750. extern void        IDL_tree_error            (IDL_tree p,
  751.                              const char *fmt,
  752.                              ...)
  753.                             G_GNUC_PRINTF (2, 3);
  754.  
  755. extern void        IDL_tree_warning        (IDL_tree p,
  756.                              int level,
  757.                              const char *fmt,
  758.                              ...)
  759.                             G_GNUC_PRINTF (3, 4);
  760.  
  761. extern const char *    IDL_tree_property_get        (IDL_tree tree,
  762.                              const char *key);
  763.  
  764. extern void        IDL_tree_property_set        (IDL_tree tree,
  765.                              const char *key,
  766.                              const char *value);
  767.  
  768. extern gboolean        IDL_tree_property_remove    (IDL_tree tree,
  769.                              const char *key);
  770.  
  771. extern void        IDL_tree_properties_copy    (IDL_tree from_tree,
  772.                              IDL_tree to_tree);
  773.  
  774. extern void        IDL_tree_remove_inhibits    (IDL_tree *tree,
  775.                              IDL_ns ns);
  776.  
  777. extern void        IDL_tree_walk            (IDL_tree p,
  778.                              IDL_tree_func_data *current,
  779.                              IDL_tree_func pre_tree_func,
  780.                              IDL_tree_func post_tree_func,
  781.                              gpointer user_data);
  782.  
  783. extern void        IDL_tree_walk_in_order        (IDL_tree p,
  784.                              IDL_tree_func tree_func,
  785.                              gpointer user_data);
  786.  
  787. extern void        IDL_tree_free            (IDL_tree root);
  788.  
  789. extern void        IDL_tree_to_IDL            (IDL_tree p,
  790.                              IDL_ns ns,
  791.                              FILE *output,
  792.                              unsigned long output_flags);
  793.  
  794. extern GString *    IDL_tree_to_IDL_string        (IDL_tree p,
  795.                              IDL_ns ns,
  796.                              unsigned long output_flags);
  797.  
  798. extern gchar *        IDL_do_escapes            (const char *s);
  799.  
  800. extern IDL_tree        IDL_resolve_const_exp        (IDL_tree p,
  801.                              IDL_tree_type type);
  802.  
  803. extern IDL_ns        IDL_ns_new            (void);
  804.  
  805. extern void        IDL_ns_free            (IDL_ns ns);
  806.  
  807. extern IDL_tree        IDL_ns_resolve_this_scope_ident    (IDL_ns ns,
  808.                              IDL_tree scope,
  809.                              IDL_tree ident);
  810.  
  811. extern IDL_tree        IDL_ns_resolve_ident        (IDL_ns ns,
  812.                              IDL_tree ident);
  813.  
  814. extern IDL_tree        IDL_ns_lookup_this_scope    (IDL_ns ns,
  815.                              IDL_tree scope,
  816.                              IDL_tree ident,
  817.                              gboolean *conflict);
  818.  
  819. extern IDL_tree        IDL_ns_lookup_cur_scope        (IDL_ns ns,
  820.                              IDL_tree ident,
  821.                              gboolean *conflict);
  822.  
  823. extern IDL_tree        IDL_ns_place_new        (IDL_ns ns,
  824.                              IDL_tree ident);
  825.  
  826. extern void        IDL_ns_push_scope        (IDL_ns ns,
  827.                              IDL_tree ident);
  828.  
  829. extern void        IDL_ns_pop_scope        (IDL_ns ns);
  830.  
  831. extern IDL_tree        IDL_ns_qualified_ident_new    (IDL_tree nsid);
  832.  
  833. extern gchar *        IDL_ns_ident_to_qstring        (IDL_tree ns_ident,
  834.                              const char *join,
  835.                              int scope_levels);
  836.  
  837. extern int        IDL_ns_scope_levels_from_here    (IDL_ns ns,
  838.                              IDL_tree ident,
  839.                              IDL_tree parent);
  840.  
  841. extern gchar *        IDL_ns_ident_make_repo_id    (IDL_ns ns,
  842.                              IDL_tree p,
  843.                              const char *p_prefix,
  844.                              int *major,
  845.                              int *minor);
  846.  
  847. #ifdef __cplusplus
  848. }
  849. #endif
  850.  
  851. #endif /* __IDL_H */
  852.